package top.kaoshanji.p3ch21a;

import java.util.ArrayList;

/**
 * 代码清单-p3ch21a-243页a：分支的节点实现
 * @author kaoshanji
 * ^_^
 * create time 2025/3/25 21:13
 */
public class Branch implements IBranch {

    // 存储子节点的信息
    private ArrayList subordinateList = new ArrayList();

    // 树枝节点的名称
    private String name = "";

    // 树枝节点的职位
    private String position = "";

    // 树枝节点的薪水
    private int salary = 0;

    // 通过构造函数传递树枝节点的参数
    public Branch(String name, String position, int salary) {
        this.name = name;
        this.position = position;
        this.salary = salary;
    }

    @Override
    public String getInfo() {
        return "名称： " + this.name + "\t 职位： " + this.position + "\t 薪水： " + this.salary;
    }

    @Override
    public void add(IBranch branch) {
        this.subordinateList.add(branch);
    }

    @Override
    public void add(ILeaf leaf) {
        this.subordinateList.add(leaf);
    }

    @Override
    public ArrayList getSubordinateInfo() {
        return this.subordinateList;
    }
}
